package org.ant.gui.menu;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JMenu;
import javax.swing.JMenuItem;


public class HWMenu extends JMenu {
	public static final String NAME = "Homework";

	private static final Integer ITEM_SIZE = 2;
	private ArrayList<JMenuItem> hwItemList;

	public HWMenu() {
		super();
		setText(NAME);
		loadItem();
	}

	protected void loadItem() {
		for (int i = 0; i < ITEM_SIZE; i++) {
			add(getHwItem(i));
		}
	}

	public JMenuItem getHwItem(int num) {
		if (hwItemList == null) {
			hwItemList = new ArrayList<JMenuItem>();
		}
		if (hwItemList.size() < num + 1) {
			JMenuItem hwItem = new JMenuItem();
			hwItem.setText("Homework" + (num + 1));
			//hwItem.addActionListener();
			hwItemList.add(hwItem);
		}
		return hwItemList.get(num);
	}
}
